﻿using System;
using System.Reflection;

// 接口
public interface IMath
{
    int Add(int a, int b);
    int Subtract(int a, int b);
}

// 实现类
public class Calculator : IMath
{
    public int Add(int a, int b) => a + b;
    public int Subtract(int a, int b) => a - b;
}

class Program
{
    static void Main(string[] args)
    {
        
        Type type = typeof(Calculator);
        object instance = Activator.CreateInstance(type);

        
        MethodInfo addMethod = type.GetMethod("Add");
        object result = addMethod.Invoke(instance, new object[] { 10, 5 });
        Console.WriteLine($"10 + 5 = {result}");

        MethodInfo subtractMethod = type.GetMethod("Subtract");
        result = subtractMethod.Invoke(instance, new object[] { 10, 5 });
        Console.WriteLine($"10 - 5 = {result}");

        Console.ReadKey();
    }
}